﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;

namespace ThreadStatic
{
 
        public static class Program

    {

        [ThreadStatic]
        public static int _field;

        public static void Main()

        {

            new Thread(() =>

               { 

                    for(int x = 0; x < 10; x++)

                    {

                        _field++;

                        Console.WriteLine("Thread A: {0}", _field);

                    }

                }).Start();


            Thread.Sleep(1000); //Se para 1 segundo para ver el funcionamiento mas despacio
            new Thread(() =>

                {
                    for(int x = 0; x < 10; x++)

                    {

                        _field++;

                        Console.WriteLine("Thread B: {0}", _field);

                    }

                }).Start();
     
            Console.ReadKey();

        }

    }
}
